package com.tom.architect.party3.day30;

// 静态代理
public class LambdaObserver<T> implements Observer<T> {
    private Consumer<T> onNext;

    // 传入被代理对象 onNext
    public LambdaObserver(Consumer<T> onNext) {
        this.onNext = onNext;
    }

    @Override
    public void onSubscribe() {
    }

    @Override
    public void onNext(T item) throws Exception {
        onNext.onNext(item);
    }

    @Override
    public void onError(Throwable e) {
    }

    @Override
    public void onComplete() {
    }
}
